package com.zxb.user.controller;

import com.zxb.common.utlis.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 网关测试
 *
 * @author zhuxiongbin
 * @date 2023/03/26
 */
@RestController
@Slf4j
public class GatewayController {

    @GetMapping("/testGateway")
    public R testGateway(HttpServletRequest request){

        String headerColor = request.getHeader("X-Request-color");
        log.info("gateway获取请求头X-Request-color: {}",headerColor);
        return R.ok();
    }

    @GetMapping("/testGateway2")
    public R testGateway2(@RequestHeader("X-Request-color")String color){
        log.info("gateway获取请求头X-Request-color: {}",color);
        return R.ok();
    }

    @GetMapping("/testGateway3")
    public R testGateway3(@RequestParam("color")String color){
        log.info("gateway获取请求参数: {}",color);
        return R.ok();
    }


}
